package dao

import "vtrip/internal/model"

func (d *Dao) FindAllComments(articleId, pageOffset, pageSize int) ([]*model.CommentPart, error) {
	comment := &model.ArticleComment{
		ArticleId: articleId,
	}
	return comment.All(d.engine, pageOffset, pageSize)
}

func (d *Dao) CreateComment(userId, articleId int, content string) error {
	comment := &model.ArticleComment{
		UserId:    userId,
		ArticleId: articleId,
		Content:   content,
	}
	return comment.Create(d.engine)
}

func (d *Dao) GetCommentReply(commentId int) ([]*model.CommentPart, error) {
	comment := &model.ArticleComment{
		Model: &model.Model{
			ID: commentId,
		},
	}

	return comment.GetReply(d.engine)
}
